﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace LightSO.ILibrary
{
    /// <summary>
    /// 定义数据仓储公共接口
    /// （实现接口需在Web.Config配置Spring容器，指定创建实例的工厂类型与程序集）
    /// </summary>
    public partial interface IRedisRepository<T> : InterfaceBase where T : EntityBase, new()
    {
        /// <summary>
        /// 根据主键获取类型为T的数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">主键字段值</param>
        /// <returns></returns>
        T Get(string id);

        /// <summary>
        /// 根据主键获取类型为T的数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">主键字段值</param>
        /// <returns></returns>
        string Get(string id, string defaultValue);

        /// <summary>
        /// 根据主键获取类型为T的数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">主键字段值</param>
        /// <returns></returns>
        void Set(object id, T item);

        /// <summary>
        /// 根据主键获取类型为T的数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">主键字段值</param>
        /// <returns></returns>
        void Set(object id, string value);

        /// <summary>
        /// 入队
        /// </summary>
        void Enqueue(string key, T t);

        /// <summary>
        /// 入队
        /// </summary>
        void Enqueue(string key, string value);

        /// <summary>
        /// 出队
        /// </summary>
        /// <typeparam name="T"><peparam>
        /// <param name="key"></param>
        /// <param name="t"></param>
        T Dequeue(string key);

        /// <summary>
        /// 出队
        /// </summary>
        /// <typeparam name="T"><peparam>
        /// <param name="key"></param>
        /// <param name="t"></param>
        string Dequeue(string key, string defaultValue = "");

        /// <summary>
        /// 设置Hash值
        /// </summary>
        /// <param name="hashId">表名</param>
        /// <param name="key">key</param>
        /// <param name="values">存储对象</param>
        /// <returns>true or false</returns>
        bool SetHash(string hashId, string key, T values);

        /// <summary>
        /// 设置Hash值
        /// </summary>
        /// <param name="hashId">表名</param>
        /// <param name="key">key</param>
        /// <param name="values">存储对象</param>
        /// <returns>true or false</returns>
        bool SetHash(string hashId, string key, string values);

        /// <summary>
        /// 获取hash值
        /// </summary>
        /// <param name="hashId">表名</param>
        /// <param name="key">key</param>
        /// <param name="values">存储对象</param>
        /// <returns></returns>
        T GetHash(string hashId, string key);

        /// <summary>
        /// 获取hash值
        /// </summary>
        /// <param name="hashId">表名</param>
        /// <param name="key">key</param>
        /// <param name="values">存储对象</param>
        /// <returns></returns>
        string GetHash(string hashId, string key, string defaultValue = "");
    }
}



